package com.wwp.wkb.base.impl;

import android.content.Context;
import android.text.TextUtils;
import android.widget.Toast;

import com.wwp.wkb.R;
import com.wwp.wkb.base.BaseView;

public class BaseViewDefault implements BaseView {
    private Context context;
    private AppProgressDialog progressDialog;

    public BaseViewDefault(Context context) {
        this.context = context;
    }

    @Override
    public void showToast(String msg) {
        Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    }

    @Override
    public void showLoading() {
        showLoading("");
    }

    @Override
    public void showLoading(String msg) {
        if (progressDialog == null) {
            progressDialog = new AppProgressDialog(context, R.style.Custom_Progress);
            if (!TextUtils.isEmpty(msg)) {
                progressDialog.setMessage(msg);
            }
        }
        progressDialog.show();
    }

    @Override
    public void disLoading() {
        if (progressDialog != null && progressDialog.isShowing()) {
            progressDialog.dismiss();
            progressDialog = null;
        }
    }
}
